package json;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public class HutoolJson {
    public static void main(String[] args) throws IOException {
        String jsonString = "{\"resultCode\":0,\"data\":{\"pageIndex\":1588,\"pageSize\":100,\"pageTotal\":1589,\"recordTotal\":158868,\"data\":[{\"id\":\"2335646564b71b00oSsY\",\"userName\":\"雄县雄州镇鼓楼二姑快餐店\",\"raName\":null,\"count\":1,\"gcType\":130201,\"gcTypeName\":\"商业用户/餐饮单位\",\"userNo\":\"2a5c1c86048244168a546ccc1c6ec27b\",\"bizCode\":\"54139303000306\",\"companyName\":\"燃气企业待补充\",\"companyId\":\"2231111116130b000623\",\"companyBizCode\":\"11111111111\",\"manageAreaName\":\"石家庄/井陉县\",\"userType\":null,\"userTypeLabel\":null,\"province\":null,\"provinceName\":null,\"city\":null,\"cityName\":\"雄安新区\",\"area\":null,\"areaName\":\"雄县\",\"contactPeople\":\"15512256238\",\"userAddr\":\"\",\"doucumentDate\":null,\"mobilePhone\":\"15512256238\",\"lastSecurityCheckDate\":\"2023-01-01\",\"houseNum\":null,\"apprStatus\":\"DON\",\"createTime\":\"2023-12-23\",\"qrCode\":null,\"creditCode\":\"92130638MA0DCRW525\",\"manageStatus\":\"NORMAL\",\"manageStatusDetail\":null,\"applyFlag\":0,\"workplace\":\"\",\"gasLocation\":null,\"gasType\":30200,\"gasTypeName\":\"液化石油气（LPG）\",\"gasUseScene\":110100,\"gasUseSceneName\":\"灶具\",\"codeExtsys\":\"2a5c1c86048244168a546ccc1c6ec27b\",\"gasConsumeType\":\"天然气\"}]}}";

        List<String> buslist = FileUtils.readLines(new File("C:\\Users\\yincaiyong\\Desktop\\json.json"), "UTF-8");

        jsonString = StringUtils.join(buslist," ");

        // 解析JSON字符串
        JSONObject jsonObject = JSONUtil.parseObj(jsonString);
        JSONObject dataObject = jsonObject.getJSONObject("data");
        JSONArray dataArray = dataObject.getJSONArray("data");

        // 提取UUID并用逗号分隔
        StringBuilder uuids = new StringBuilder();
        for (int i = 0; i < dataArray.size(); i++) {
            JSONObject item = dataArray.getJSONObject(i);
            String id = item.getStr("id");
            if (i > 0) {
                uuids.append(",");
            }
            uuids.append(id);
        }

        // 输出结果
        System.out.println(uuids.toString());
    }
}
